#ifndef ECGSIGNAL_H
#define ECGSIGNAL_H
#include <QByteArray>
#include <QDataStream>
#include <QDebug>
#include <QFile>
#include <QObject>
#include <QString>
#include <QVector>
#include <cstdint>
#include "ecg.h"

class EcgSignal : public QObject {
    Q_OBJECT
private:
    explicit EcgSignal(QObject* parent = nullptr);
    Ecg& ecg = Ecg::getInstance();

public:
    static EcgSignal& getInstance();
    // 删除拷贝构造函数和赋值运算符，防止拷贝实例
    EcgSignal(const EcgSignal&) = delete;
    EcgSignal& operator=(const EcgSignal&) = delete;
    // int16_t** data; //信号数据，二维数组
    QVector<QVector<int16_t>> data;//信号数据，二维数组
    int numberChannels = 0; //通道数
    int signalSize = 0;//单个通道最大信号数
    void readBinaryFile(const QString& filePath);
    Q_INVOKABLE QVector<QVector<int16_t>> getEcgSignalFragment(int start, int duration);
    Q_INVOKABLE int getSignalSize() const;
    void setSignalSize(int newSignalSize);
};

#endif // ECGSIGNAL_H
